<?php

namespace App\Models\Pay ;

use Illuminate\Database\Eloquent\Model;

class SysOnlineParameter extends Model
{

    protected $table = 'sys_online_parameter';

    protected $primaryKey = 'payTypeID';

    public $timestamps = false;

    public $incrementing = false;

    //查询单条支付参数信息
    public static function getOnlineInfo( $arg_array  ){

        if ( !isset( $arg_array['payTypeID'],$arg_array['area_id'] ) || !ebsig_is_int( $arg_array['payTypeID'] ) ) {
            return null;
        }

        $where = [];

        //支付方式ID
        if (isset($arg_array['payTypeID']) && ebsig_is_int($arg_array['payTypeID'])) {
            $where[] = [ 'payTypeID' , '=' , $arg_array['payTypeID']];
        }
        //门店大区ID
        if ( isset( $arg_array['area_id'] ) && ebsig_is_int( $arg_array['area_id'] )) {
            $where[] = [ 'area_id' , '=' , $arg_array['area_id']];
        }

        $online_data = self::where($where)->first();
        if ( !$online_data ) {
            return null;
        }

        $online_data = $online_data->toArray();

        if( $online_data['app_parmas_json'] ){
            $online_data['app_parmas'] = json_decode($online_data['app_parmas_json'], true);
        }else{
            $online_data['app_parmas'] = null;
        }

        return $online_data;

    }

}
